<?php


namespace app\api\controller;


use app\BaseController;
use app\Request;
use broadcast\services\UtilService as Util;

use broadcast\payment\AlipayPay;
use broadcast\payment\WechatPay;


class PayController extends BaseController
{
    // 微信充值
    public function  wetPay (Request $request)
    {
        $data = Util::postMore([
            'type' => 'computer',
            'money' => 0
        ]);
        session("website",$request->website);
        $info = array();
        $config = [
            'appid' => $info['wechat_appid'],
            'app_id' => $info['wechat_app_id'],
            'miniapp_id' => $info['wechat_miniapp_id'],
            'mch_id'     => $info['wechat_mch_id'],
            'key'        => $info['wechat_key'],
            'cert_client' => $info['wechat_cert_client'],
            'cert_key'    => $info['wechat_cert_key'],
            "notify_url"  => $info['backend_domain'] . 'wechat/notify?website='.session("website")
        ];
        $wechatPay = new WechatPay($config);
        $list = $wechatPay->pay($data);
        return app("app")->success("充值成功");
    }

    // 支付宝充值
    public function AlipayPay (Request $request)
    {
        $data = Util::postMore([
            'type' => 'computer',
            'money' => 0
        ]);
        session("website",$request->website);
        $info = array();
        $config = [
            'app_id' => $info['app_id'],
            'ali_public_key' => $info['ali_public_key'],
            'private_key' => $info['private_key'],
            "notify_url"  => $info['backend_domain'] . 'alipay/notify?website='.session("website")
        ];
        $AlipayPay = new AlipayPay($config);
        $list = $AlipayPay->pay($data);
    } 



    // 微信后台回调
    public function wechatNotify ()
    {
        $data = Util::getMore([
            "website" => ''
        ]);
        
    }

    // 微信后台回调
    public function alipayNotify ()
    {
        $data = Util::getMore([
            "website" => ''
        ]);

    }
}